/**
*      author: Y_Yao
*      created: 2024-12-28 20:09:37
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 5e5 + 7;
int k;
string S,T;

void solve()
{
    cin >> k;
    cin >> S;
    cin >> T;
    int n = S.size();
    int m = T.size();

    if(abs(n - m) > 1)
    {
        cout << "No" << endl;
        return;
    }

    int i = 0,j = 0;
    int flag = 1;
    while(i < S.size() && j < T.size())
    {
        if(S[i] == T[j]) 
        {
            i++,j++;
            continue;
        }
        if(flag == 0)
        {
            cout << "No" << endl;
            return;
        }

        //删除
        if(i != S.size() - 1 && S[i + 1] == T[j])
        {
            flag = 0;
            i++;
            continue;
        }

        //替换
        if( j != T.size() && S[i] == T[j + 1])
        {
            flag = 0;
            j++;
            continue;
        }

        flag = 0;
        i++;
        j++;
    }

    cout << "Yes" << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}